**NB**: If you've created your app with [thredded_create_app](https://github.com/thredded/thredded_create_app) v0.1.12+, everything below has already been set up for you.

Here is how you can use [roadie-rails](https://github.com/Mange/roadie-rails) to style the emails.

Here is [a demo of what these styles look like](https://thredded.org/emails/en/thredded__post_mailer_preview-post_notification).

First, the email template (`app/views/layouts/mailer.html.erb`):

```erb
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <%= stylesheet_link_tag 'email' %>
</head>
<body>
<%= yield %>
</body>
</html>
```

Email styles (`email.scss`):

```scss
@import "variables";
// @import "thredded-coderay"; // only if you use the CodeRay plugin
@import "thredded/email";
```

Application mailer (`app/mailers/application_mailer.rb`):

```ruby
class ApplicationMailer < ActionMailer::Base
  include Roadie::Rails::Automatic
  layout 'mailer'
end
```

Thredded initializer (`config/initializers/thredded.rb`):

```ruby
Thredded.parent_mailer = 'ApplicationMailer'
```

Roadie initializer (`config/initializers/roadie.rb`):

```ruby
Rails.application.config.roadie.before_transformation = Thredded::EmailTransformer
```

Production environment config (`config/environments/production.rb`):

```ruby
config.roadie.url_options = config.action_mailer.default_url_options = {
  host: '[SET ME] example.com',
  protocol: 'https'
}
# Roadie requires this to be nil
config.action_mailer.asset_host = nil
```